// ----------------------------------
// RSDK Project: Sonic 1
// Script Description: Goggles Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// ========================
// Aliases
// ========================

private alias object.state : object.setupDone

private alias object.value0 : object.targetPlayer
private alias object.value1 : object.frameTable

// Player Aliases
private alias object.type 		: player.type
private alias object.animation	: player.animation
private alias object.direction	: player.direction
private alias object.rotation	: player.rotation
private alias object.xpos 		: player.xpos
private alias object.ypos 		: player.ypos
private alias object.frame 		: player.frame

private alias -1 : DRAWORDER_PLAYER


// ========================
// Tables
// ========================

private table Goggles_frameTableSonic
	1 		// ANI_STOPPED
	2 		// ANI_WAITING
	0 		// ANI_BORED (blank)
	8 		// ANI_LOOKINGUP
	11 		// ANI_LOOKINGDOWN
	14 		// ANI_WALKING
	20 		// ANI_RUNNING
	24 		// ANI_SKIDDING
	0 		// ANI_PEELOUT - even if there's logic for it in other places, it's blank here
	0 		// ANI_SPINDASH
	26 		// ANI_JUMPING
	31 		// ANI_BOUNCING
	32 		// ANI_HURT, can't be seen if the Goggles were given Debug Mode but can be seen if the Goggles are in visual-only mode (see Startup)
	0 		// ANI_DYING
	0 		// ANI_DROWNING
	34 		// ANI_FANROTATE
	39 		// ANI_BREATHING
	40 		// ANI_PUSHING
	44 		// ANI_FLAILING1
	44 		// ANI_FLAILING2
	0		// "Sliding" - blank and unused
	46 		// ANI_HANGING
	0 		// ANI_DROPPING
	48 		// ANI_CLINGING
	0		// ANI_FLYING
	0		// ANI_FLYINGTIRED
	0 		// ANI_SWIMMING
	0 		// ANI_SWIMMINGTIRED
	0 		// ANI_GLIDING
	0 		// ANI_GLIDING_DROP
	0 		// ANI_GLIDING_STOP
	0 		// ANI_CLIMBING
	0 		// ANI_LEDGEPULLUP
	0 		// "Corkscrew H" - blank and unused
	0 		// "Corkscrew V" - blank and unused
	32 		// ANI_WATERSLIDE
	0 		// ANI_CONTINUE
	0 		// ANI_CONTINUE_UP
	0 		// ANI_SUPER_TRANSFORM
	0 		// ANI_FLY_LIFT_DOWN
	0 		// ANI_FLY_LIFT_UP
	0 		// ANI_FLY_LIFT_TIRED
	0 		// ANI_SWIM_LIFT
end table


private table Goggles_frameTableTails
	50 		// ANI_STOPPED
	51 		// ANI_WAITING
	0 		// ANI_BORED (blank)
	54 		// ANI_LOOKINGUP
	55 		// ANI_LOOKINGDOWN
	56 		// ANI_WALKING
	64 		// ANI_RUNNING
	52 		// ANI_SKIDDING
	64 		// ANI_PEELOUT - used it's not really Tails's "Peel Out", actually his fastest run anim
	0 		// ANI_SPINDASH
	188 		// ANI_JUMPING
	70 		// ANI_BOUNCING
	72 		// ANI_HURT, not seen if Goggles are from Debug Mode but can be seen if Goggles are only visual (see Startup)
	0 		// ANI_DYING
	0 		// ANI_DROWNING
	74 		// ANI_FANROTATE
	79 		// ANI_BREATHING
	80 		// ANI_PUSHING
	84 		// ANI_FLAILING1
	84 		// ANI_FLAILING2
	0 		// "Sliding" - blank and unused
	0 		// ANI_HANGING
	0 		// ANI_DROPPING
	86 		// ANI_CLINGING
	88 		// ANI_FLYING - unused because Tails is always swimming underwater. This data for it still fits fine though
	90 		// ANI_FLYINGTIRED - unused for the same reason as above, this one also works fine
	92 		// ANI_SWIMMING
	97 		// ANI_SWIMMINGTIRED
	0 		// ANI_GLIDING
	0 		// ANI_GLIDING_DROP
	0 		// ANI_GLIDING_STOP
	0 		// ANI_CLIMBING
	0 		// ANI_LEDGEPULLUP
	0 		// "Corkscrew H" - blank and unused
	0 		// "Corkscrew V" - blank and unused
	72 		// ANI_WATERSLIDE
	0 		// ANI_CONTINUE
	0 		// ANI_CONTINUE_UP
	0 		// ANI_SUPER_TRANSFORM
	0 		// ANI_FLY_LIFT_DOWN
	0 		// ANI_FLY_LIFT_UP
	0 		// ANI_FLY_LIFT_TIRED
	0 		// ANI_SWIM_LIFT
end table


private table Goggles_frameTableKnuckles
	100 	// ANI_STOPPED
	101 	// ANI_WAITING
	0 		// ANI_BORED (blank)
	114 	// ANI_LOOKINGUP
	117 	// ANI_LOOKINGDOWN
	120 	// ANI_WALKING
	128 	// ANI_RUNNING
	132 	// ANI_SKIDDING
	0 		// ANI_PEELOUT
	0 		// ANI_SPINDASH
	134 	// ANI_JUMPING
	142 	// ANI_BOUNCING
	143 	// ANI_HURT, as with the other characters this frame can't be seen if the Goggles were spawned via Debug Mode,
			// but they can be seen if the Goggles were placed in the scene (once again, see Startup)
	0 		// ANI_DYING
	0 		// ANI_DROWNING
	145 	// ANI_FANROTATE
	155 	// ANI_BREATHING
	156 	// ANI_PUSHING
	160 	// ANI_FLAILING1
	160 	// ANI_FLAILING2
	0 		// "Sliding" - blank and unused
	0 		// ANI_HANGING
	0 		// ANI_DROPPING
	172 	// ANI_CLINGING
	0 		// ANI_FLYING
	0 		// ANI_FLYINGTIRED
	0 		// ANI_SWIMMING
	0 		// ANI_SWIMMINGTIRED
	174 	// ANI_GLIDING
	177 	// ANI_GLIDING_DROP
	179 	// ANI_GLIDING_STOP
	181 	// ANI_CLIMBING
	187 	// ANI_LEDGEPULLUP
	0 		// "Corkscrew H" - blank and unused
	0 		// "Corkscrew V" - blank and unused
	144  	// ANI_WATERSLIDE
	0 		// ANI_CONTINUE
	0 		// ANI_CONTINUE_UP
	0 		// ANI_SUPER_TRANSFORM
	0 		// ANI_FLY_LIFT_DOWN
	0 		// ANI_FLY_LIFT_UP
	0 		// ANI_FLY_LIFT_TIRED
	0 		// ANI_SWIM_LIFT
end table


// ========================
// Events
// ========================

event ObjectUpdate
	// This object can't setup in Startup due to how it works, so setup is done on the first frame of its Update instead
	if object.setupDone == false
		switch stage.playerListPos
		case PLAYER_SONIC_A
		case PLAYER_SONIC_TAILS_A
			object.frameTable = Goggles_frameTableSonic
			break
			
		case PLAYER_TAILS_A
			object.frameTable = Goggles_frameTableTails
			break
			
		case PLAYER_KNUCKLES_A
			object.frameTable = Goggles_frameTableKnuckles
			break
			
		end switch
		
		object.setupDone++
	end if
end event


event ObjectDraw
	// Focus on the assigned player
	currentPlayer = object.targetPlayer
	
	temp0 = player[currentPlayer].ypos
	temp0 >>= 16
	
	// Only draw when the player is underwater
	if temp0 >= stage.waterLevel
		// Face the same way the player is facing
		object.direction = player[currentPlayer].direction
		
		// Check if the player is in an animation that rotates
		CheckEqual(player[currentPlayer].animation, ANI_WALKING)
		temp0 = checkResult
		CheckEqual(player[currentPlayer].animation, ANI_RUNNING)
		temp0 |= checkResult
		CheckEqual(player[currentPlayer].animation, ANI_PEELOUT) // For Tails, the "Peelout" anim is his fastest run anim
		temp0 |= checkResult
		if temp0 == true
			// Player is in a rotatable animation, make the goggles match the player's quarter rotation
			object.rotation = player[currentPlayer].rotation

			if object.rotation >= 256
				object.rotation += 40
			else
				object.rotation += 16
			end if

			object.rotation &= 448
		else
			// Player is an a normal, upright animation so keep the goggles unrotated
			object.rotation = 0
		end if
		
		// Get the starting frame the goggles should use
		object.frame = player[currentPlayer].frame
		GetTableValue(temp0, player[currentPlayer].animation, object.frameTable)
		
		if temp0 == 0
			// Blank, that means this animation is one that shouldn't have goggles shown
			object.frame = 0
		else
			object.frame += temp0
			
			// Special exceptions for some of the special sticklers
			
			if object.frameTable == Goggles_frameTableTails
				if player[currentPlayer].animation == ANI_WAITING
					if player[currentPlayer].frame <= 26
						// Looking ahead
						object.frame = 50
					else
						if player[currentPlayer].frame <= 45
							// Looking at the camera
							object.frame = 51
						else
							object.frame = 50
						end if
					end if
				else
					// Tails should never be flying underwater - he's swimming instead - so this following stuff somewhat goes unused
					if player[currentPlayer].animation == ANI_FLYINGTIRED
						// The player's animation has 12 frames while there are only two frames of goggle data for it, crunch them up a little
						
						object.frame = player[currentPlayer].frame
						object.frame /= 6
						object.frame += 90
					end if
				end if
			else
				if object.frameTable == Goggles_frameTableKnuckles
					if player[currentPlayer].animation == ANI_WAITING
						if player[currentPlayer].frame <= 53
							// Tapping his foot
							object.frame = 100
						else
							if player[currentPlayer].frame <= 58
								// Looking at the camera
								object.frame = 101
							else
								if player[currentPlayer].frame == 59
									// First frame of the air boxing sequence
									object.frame = 102
								else
									if player[currentPlayer].frame <= 91
										// Boxing up, ready to go
										// In this part of the animation, he's moving in groups of 3 repeated frames
										object.frame = player[currentPlayer].frame
										object.frame -= 60
										object.frame &= 3
										object.frame += 103
									else
										// Punching
										object.frame = player[currentPlayer].frame
										object.frame -= 92
										object.frame += 107
									end if
								end if
							end if
						end if
					else
						CheckEqual(player[currentPlayer].animation, ANI_FLAILING1)
						temp0 = checkResult
						CheckEqual(player[currentPlayer].animation, ANI_FLAILING2)
						temp0 |= checkResult
						if temp0 == true
							if player[currentPlayer].frame < 12
								// In this part of the animation, all his frames are in groups of 2
								object.frame = player[currentPlayer].frame
								object.frame >>= 1
								object.frame += 160
							else
								if player[currentPlayer].frame < 27
									// The same frame is repeated 14 times
									object.frame = 166
								else
									if player[currentPlayer].frame < 30
										// Similarly, the next three frames are all the same sprite too
										object.frame = 167
									else
										if player[currentPlayer].frame < 33
											// And one more, another group of 3 dupes
											object.frame = 168
										else
											// From here, all sprites are in groups of two once again
											object.frame = player[currentPlayer].frame
											object.frame -= 33
											object.frame >>= 1
											object.frame %= 3
											object.frame += 169
										end if
									end if
								end if
							end if
						end if
					end if
				end if
			end if
		end if
		
		if player[currentPlayer].type != TypeName[Debug Mode]
			DrawSpriteFX(object.frame, FX_ROTATE, player[currentPlayer].xpos, player[currentPlayer].ypos)
		end if
	end if
end event


event ObjectStartup
	LoadSpriteSheet("Global/Items.gif")
	
	// Goggle frames
	// There are only a couple of actual goggle sprites, these are all pretty much the same thing but with different offsets
	// All frames are labelled with the character and animation they correspond to
	
	// #0 - Empty frame
	SpriteFrame(0, 0, 1, 1, 1, 1)
	
	// #1 - Sonic's ANI_STOPPED
	SpriteFrame(-4, -12, 12, 9, 118, 71)
	
	// #2 - #7 - Sonic's ANI_WAITING
	SpriteFrame(-7, -11, 15, 9, 118, 81)
	SpriteFrame(-7, -11, 15, 9, 118, 81)
	SpriteFrame(-7, -11, 15, 9, 118, 81)
	SpriteFrame(-7, -11, 15, 9, 118, 81)
	SpriteFrame(-7, -11, 15, 9, 118, 81)
	SpriteFrame(-7, -11, 15, 9, 118, 81)
	
	// ANI_BORED has no goggle data
	
	// #8 - #10 - Sonic's ANI_LOOKINGUP
	SpriteFrame(-4, -12, 12, 9, 118, 71)
	SpriteFrame(-5, -12, 12, 10, 127, 102)
	SpriteFrame(-6, -13, 12, 10, 127, 102)
	
	// #11 - #13 - Sonic's ANI_LOOKINGDOWN
	SpriteFrame(-4, -12, 12, 9, 118, 71)
	SpriteFrame(-1, -4, 14, 11, 150, 118)
	SpriteFrame(-1, 10, 9, 8, 140, 102)
	
	// #14 - #19 - Sonic's ANI_WALKING
	SpriteFrame(0, -11, 12, 9, 118, 71)
	SpriteFrame(0, -12, 12, 9, 118, 71)
	SpriteFrame(0, -11, 12, 9, 118, 71)
	SpriteFrame(3, -11, 8, 9, 118, 102)
	SpriteFrame(3, -12, 8, 9, 118, 102)
	SpriteFrame(3, -11, 8, 9, 118, 102)
	
	// #20 - #23 - Sonic's ANI_RUNNING
	SpriteFrame(3, -9, 12, 9, 118, 71)
	SpriteFrame(3, -9, 12, 9, 118, 71)
	SpriteFrame(3, -9, 12, 9, 118, 71)
	SpriteFrame(3, -9, 12, 9, 118, 71)
	
	// #24 - #25 - Sonic's ANI_SKIDDING
	SpriteFrame(-9, -9, 15, 9, 118, 81)
	SpriteFrame(-9, -9, 15, 9, 118, 81)
	
	// Sonic's ANI_PEELOUT has no goggle data
	// There is still some code for it, see ObjectDraw
	
	// Sonic's ANI_SPINDASH is blank as well
	
	// #26 - #30 - Sonic's ANI_JUMPING
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(3, -7, 8, 9, 118, 102)
	SpriteFrame(-1, 3, 9, 8, 140, 102)
	SpriteFrame(-11, -2, 8, 9, 142, 92)
	SpriteFrame(-8, -11, 9, 8, 118, 123)
	
	// #31 - Sonic's ANI_BOUNCING
	SpriteFrame(-4, -17, 12, 10, 127, 102)
	
	// #32 - #33 - Sonic's ANI_HURT and ANI_WATERSLIDE
	SpriteFrame(-8, -10, 15, 9, 118, 81)
	SpriteFrame(-8, -10, 15, 9, 118, 81)
	
	// Sonic's ANI_DYING and ANI_DROWNING are blank too
	
	// #34 - #38 - Sonic's ANI_FANROTATE
	SpriteFrame(9, -5, 12, 9, 118, 71)
	SpriteFrame(-8, -5, 16, 8, 118, 113)
	SpriteFrame(-21, -5, 12, 9, 130, 92)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	
	// #39 - Sonic's ANI_BREATHING
	SpriteFrame(-4, -18, 12, 10, 127, 102)
	
	// #40 - #43 - Sonic's ANI_PUSHING
	SpriteFrame(-5, -7, 15, 9, 118, 81)
	SpriteFrame(-5, -8, 15, 9, 118, 81)
	SpriteFrame(-5, -7, 15, 9, 118, 81)
	SpriteFrame(-5, -8, 15, 9, 118, 81)
	
	// #44 - #45 - Sonic's ANI_FLAILING1 and ANI_FLAILING2
	SpriteFrame(-10, -13, 15, 9, 118, 81)
	SpriteFrame(-8, -12, 15, 9, 118, 81)
	
	// "Sliding" anim doesn't have any data
	
	// #46 - #47 - Sonic's ANI_HANGING
	SpriteFrame(-3, -9, 12, 9, 118, 71)
	SpriteFrame(-3, -9, 12, 9, 118, 71)
	
	// Sonic's ANI_DROPPING doesn't have any goggle data either
	
	// #48 - #49 - Sonic's ANI_CLINGING
	SpriteFrame(-13, -10, 14, 13, 135, 113)
	SpriteFrame(-12, -10, 14, 13, 135, 113)
	
	// Now, Tails's frames
	
	// #50 - Tails's ANI_STOPPED
	SpriteFrame(-3, -15, 12, 9, 118, 71)
	
	// #51 - Tails's ANI_WAITING
	// Note that there's a special exception for this,
	// go see ObjectDraw for more info
	SpriteFrame(-6, -15, 16, 9, 118, 113)

	// #52 - #53 - I moved the skidding here to leave room for Rainbow's flying
	SpriteFrame(-5, -15, 12, 9, 118, 71)
	SpriteFrame(-5, -15, 12, 9, 118, 71)
	
	// Tails's ANI_BORED is empty
	
	// #54 - Tails's ANI_LOOKINGUP
	SpriteFrame(-5, -16, 12, 10, 127, 102)
	
	// #55 - Tails's ANI_LOOKINGDOWN
	SpriteFrame(-1, -5, 12, 9, 118, 71)
	
	// #56 - #63 - Tails's ANI_WALKING
	SpriteFrame(4, -11, 8, 9, 118, 102)
	SpriteFrame(5, -11, 8, 9, 118, 102)
	SpriteFrame(6, -10, 8, 9, 118, 102)
	SpriteFrame(6, -10, 8, 9, 118, 102)
	SpriteFrame(5, -10, 8, 9, 118, 102)
	SpriteFrame(5, -10, 8, 9, 118, 102)
	SpriteFrame(4, -10, 8, 9, 118, 102)
	SpriteFrame(4, -11, 8, 9, 118, 102)
	
	// #64 - #67 - Tails's ANI_RUNNING and ANI_PEELOUT
	// Note that Tails's ANI_PEELOUT is his fastest run anim
	SpriteFrame(7, -7, 8, 9, 118, 102)
	SpriteFrame(7, -7, 8, 9, 118, 102)
	SpriteFrame(7, -7, 8, 9, 118, 102)
	SpriteFrame(7, -7, 8, 9, 118, 102)
	SpriteFrame(7, -7, 8, 9, 118, 102)
	SpriteFrame(7, -7, 8, 9, 118, 102)
	
	// #70 - #71 - Tails's ANI_BOUNCING
	SpriteFrame(-3, -16, 15, 9, 118, 81)
	SpriteFrame(-3, -16, 15, 9, 118, 81)
	
	// #72 - #73 - Tails's ANI_HURT and ANI_WATERSLIDE
	SpriteFrame(-9, -14, 15, 9, 118, 81)
	SpriteFrame(-9, -14, 15, 9, 118, 81)
	
	// #74 - #78 - Tails's ANI_FANROTATE
	SpriteFrame(4, -7, 12, 9, 118, 71)
	SpriteFrame(-8, -7, 16, 8, 118, 113)
	SpriteFrame(-16, -7, 12, 9, 130, 92)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	
	// #79 - Tails's ANI_BREATHING
	SpriteFrame(-5, -17, 15, 9, 118, 81)
	
	// #80 - #83 - Tails's ANI_PUSHING
	SpriteFrame(0, -6, 10, 11, 49, 105)
	SpriteFrame(0, -5, 10, 11, 49, 105)
	SpriteFrame(0, -6, 10, 11, 49, 105)
	SpriteFrame(0, -5, 10, 11, 49, 105)
	
	// #84 - #85 - Tails's ANI_FLAILING1 and ANI_FLAILING2
	SpriteFrame(-2, -21, 15, 9, 118, 81)
	SpriteFrame(0, -18, 15, 9, 118, 81)
	
	// #86 - #87 - Tails's ANI_CLINGING
	SpriteFrame(-13, -5, 14, 13, 135, 113)
	SpriteFrame(-12, -5, 14, 13, 135, 113)
	
	// #88 - #89 - Tails's ANI_FLYING
	// Unused, since Tails doesn't fly underwater
	SpriteFrame(-1, -4, 12, 9, 118, 71)
	SpriteFrame(-1, -4, 12, 9, 118, 71)
	
	// #90 - #91 - Tails's ANI_FLYINGTIRED
	// This animation has a special exceptions as well,
	// go see ObjectDraw for more info
	// In spite of that though, this one is unused too
	SpriteFrame(-1, -4, 12, 9, 118, 71)
	SpriteFrame(-1, -5, 12, 9, 118, 71)
	
	// #92 - #96 - Tails's ANI_SWIMMING
	SpriteFrame(2, -9, 15, 9, 118, 81)
	SpriteFrame(2, -9, 15, 9, 118, 81)
	SpriteFrame(2, -9, 15, 9, 118, 81)
	SpriteFrame(2, -9, 15, 9, 118, 81)
	SpriteFrame(2, -9, 15, 9, 118, 81)
	
	// #97 - #99 - Tails's ANI_SWIMMINGTIRED
	SpriteFrame(2, -6, 15, 9, 118, 81)
	SpriteFrame(2, -6, 15, 9, 118, 81)
	SpriteFrame(2, -6, 15, 9, 118, 81)
	
	// #100 - Knuckles's ANI_STOPPED
	SpriteFrame(-5, -17, 15, 9, 118, 81)
	
	// #101 - #113 - Knuckles's ANI_WAITING
	// Note that there's also a special exception for this,
	// go see ObjectDraw for more info
	SpriteFrame(-6, -16, 15, 9, 118, 81)
	SpriteFrame(-4, -17, 15, 9, 118, 81)
	SpriteFrame(-5, -16, 15, 9, 118, 81)
	SpriteFrame(-4, -16, 15, 9, 118, 81)
	SpriteFrame(-3, -15, 15, 9, 118, 81)
	SpriteFrame(-4, -15, 15, 9, 118, 81)
	SpriteFrame(-5, -15, 15, 9, 118, 81)
	SpriteFrame(-4, -15, 15, 9, 118, 81)
	SpriteFrame(-5, -15, 15, 9, 118, 81)
	SpriteFrame(-4, -15, 15, 9, 118, 81)
	SpriteFrame(7, -15, 8, 9, 118, 102)
	SpriteFrame(-5, -16, 15, 9, 118, 81)
	SpriteFrame(-4, -17, 15, 9, 118, 81)
	
	// #114 - #116 - Knuckles's ANI_LOOKINGUP
	SpriteFrame(-5, -17, 15, 9, 118, 81)
	SpriteFrame(-5, -19, 12, 10, 127, 102)
	SpriteFrame(-7, -20, 12, 10, 127, 102)
	
	// #117 - #119 - Knuckles's ANI_LOOKINGDOWN
	SpriteFrame(-5, -17, 15, 9, 118, 81)
	SpriteFrame(-3, -9, 12, 9, 118, 71)
	SpriteFrame(-2, -1, 12, 9, 118, 71)
	
	// #120 - #127 - Knuckles's ANI_WALKING
	SpriteFrame(-1, -11, 12, 9, 118, 71)
	SpriteFrame(3, -12, 8, 9, 118, 102)
	SpriteFrame(3, -14, 8, 9, 118, 102)
	SpriteFrame(0, -12, 12, 9, 118, 71)
	SpriteFrame(-3, -12, 12, 9, 118, 71)
	SpriteFrame(-3, -13, 15, 9, 118, 81)
	SpriteFrame(-4, -14, 15, 9, 118, 81)
	SpriteFrame(-2, -13, 12, 9, 118, 71)
	
	// #128 - #131 - Knuckles's ANI_RUNNING
	SpriteFrame(-3, -12, 12, 9, 118, 71)
	SpriteFrame(-3, -12, 12, 9, 118, 71)
	SpriteFrame(-3, -12, 12, 9, 118, 71)
	SpriteFrame(-3, -12, 12, 9, 118, 71)
	
	// #132 - #133 - Knuckles's ANI_SKIDDING
	// This one's a weird case - in the initial release of S1, Knuckles's skidding anim was two frames
	// However, it later got changed to hold four, but this object was never updated to account for that
	SpriteFrame(-5, -13, 15, 9, 118, 81)
	SpriteFrame(-10, -12, 15, 9, 118, 81)
	
	// #134 - #141 - Knuckles's ANI_JUMPING
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(2, 1, 9, 8, 140, 102)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(-10, 2, 8, 9, 142, 92)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(-11, -10, 9, 8, 118, 123)
	SpriteFrame(-6, -17, 9, 8, 118, 123)
	SpriteFrame(-8, -16, 15, 9, 118, 81)
	
	// #142 - Knuckles's ANI_BOUNCING
	SpriteFrame(-10, -13, 15, 9, 118, 81)
	
	// #143 - Knuckles's ANI_HURT and ANI_WATERSLIDE
	SpriteFrame(2, -8, 12, 9, 118, 71)
	
	// #144 - Unused?
	SpriteFrame(-2, -7, 15, 9, 118, 81)
	
	// #145 - #154 - Knuckles's ANI_FANROTATE
	SpriteFrame(-7, -5, 16, 9, 118, 113)
	SpriteFrame(-13, -7, 15, 9, 69, 106)
	SpriteFrame(-14, -8, 12, 9, 130, 92)
	SpriteFrame(-14, -9, 8, 9, 60, 106)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(6, -9, 8, 9, 118, 102)
	SpriteFrame(-3, -17, 15, 9, 118, 81)
	SpriteFrame(1, -13, 12, 9, 118, 71)
	
	// #155 - Knuckles's ANI_BREATHING
	SpriteFrame(-4, -14, 15, 9, 118, 81)
	
	// #156 - #159 - Knuckles's ANI_PUSHING
	SpriteFrame(1, -13, 12, 9, 118, 71)
	SpriteFrame(4, -14, 8, 9, 118, 102)
	SpriteFrame(1, -10, 12, 9, 118, 71)
	SpriteFrame(2, -15, 15, 9, 118, 81)
	
	// #160 - #171 - Knuckles's ANI_FLAILING1 and ANI_FLAILING2
	// This animation is also one with special exceptions,
	// go see ObjectDraw for more info
	SpriteFrame(5, -12, 16, 9, 118, 113)
	SpriteFrame(3, -26, 14, 13, 135, 113)
	SpriteFrame(7, -16, 6, 7, 128, 123)
	SpriteFrame(3, -16, 11, 10, 118, 91)
	SpriteFrame(-1, -22, 14, 13, 135, 113)
	SpriteFrame(4, -20, 14, 13, 135, 113)
	SpriteFrame(6, -18, 14, 13, 135, 113)
	SpriteFrame(5, -20, 14, 13, 135, 113)
	SpriteFrame(3, -21, 14, 13, 135, 113)
	SpriteFrame(3, -20, 14, 13, 135, 113)
	SpriteFrame(-13, -11, 11, 10, 118, 91)
	SpriteFrame(-12, -11, 11, 10, 118, 91)
	
	// #172 - #173 - Knuckles's ANI_CLINGING
	SpriteFrame(-7, -5, 16, 9, 118, 113)
	SpriteFrame(-2, -7, 15, 9, 118, 81)
	
	// #174 - #176 - Knuckles's ANI_GLIDING
	SpriteFrame(2, -8, 12, 9, 118, 71)
	SpriteFrame(2, -13, 12, 9, 118, 71)
	SpriteFrame(0, -17, 12, 9, 118, 71)
	
	// #177 - #178 - Knuckles's ANI_GLIDING_DROP
	SpriteFrame(3, -3, 12, 9, 118, 71)
	SpriteFrame(-4, -6, 15, 9, 118, 81)
	
	// #179 - #180 - Knuckles's ANI_GLIDING_STOP
	SpriteFrame(-12, -15, 12, 9, 118, 71)
	SpriteFrame(-13, -15, 12, 9, 118, 71)
	
	// #181 - #186 - Knuckles's ANI_CLIMBING
	SpriteFrame(-12, -16, 12, 9, 118, 71)
	SpriteFrame(-12, -15, 12, 9, 118, 71)
	SpriteFrame(-13, -15, 12, 9, 118, 71)
	SpriteFrame(-12, -16, 12, 9, 118, 71)
	SpriteFrame(-4, -20, 8, 9, 118, 102)
	SpriteFrame(-3, -21, 8, 9, 118, 102)
	
	// #187 - Knuckles's ANI_LEDGEPULLUP
	// This one seems to be incomplete, with only one frame
	SpriteFrame(-8, -23, 15, 9, 118, 81)

	// #188 - Rainbow's ANI_JUMPING
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(-5, -8, 8, 9, 118, 102)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(-1, -5, 9, 8, 140, 102)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(-3, -1, 8, 9, 142, 192)
	SpriteFrame(0, 0, 1, 1, 1, 1)
	SpriteFrame(-8, -3, 9, 8, 118, 123)
	
	// Amy doesn't have any Goggles frames in Origins Plus, honestly I don't blame them for not bothering
	
	// Look for goggle objects placed in the current scene
	foreach (TypeName[Goggles], arrayPos0, ALL_ENTITIES)
		// Short explanation - placing goggles in a scene will allow Sonic to have goggles on start,
		//   but they won't function like normal goggles
		//   Instead, they'll be purely cosmetic, which means that Sonic can still get hit and stuff
		//   However, even if he does get hit, he'll still keep the goggles on
		//   This feature is another unused part of this already unused object,
		//   to utilise it just place a Goggles object anywhere in a scene
		
		// Move to the P1 shield object slot
		arrayPos1 = playerCount
		
		// Move currentPlayer to P1 slot (? - nothing gets done with this, but currentPlayer *would* need to be set up if using Player_ApplyShield, maybe that's how it was in earlier versions?)
		currentPlayer = 0
		
		// Place some goggles in the shield slot and init its values
		ResetObjectEntity(arrayPos1, TypeName[Goggles], 0, 0, 0)
		object[arrayPos1].priority = PRIORITY_ACTIVE
		object[arrayPos1].targetPlayer = 0
		object[arrayPos1].drawOrder = DRAWORDER_PLAYER
		
		// Remove the goggle object from the scene, as now it's been moved to the dedicated shield slot
		ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
	next
	
	// Store the Goggle Type ID to the corresponding global variable
	// (Even if the script is in the Global folder, it's not actually a global object - it's an LZ stage-specific object instead
	//   so because of that the Goggles don't even have a Type ID by default, since they don't really exist normally)
	goggleType = TypeName[Goggles]
end event


// ========================
// Editor Events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Global/Items.gif")
	SpriteFrame(-4, -12, 12, 9, 118, 71)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event